/**
 * Project: topdt-jbpm
 * Copyright 2013  Top Digital Technology  Co. Ltd.
 * All right reserved.
 */
package com.topdt.jbpm.service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.topdt.jbpm.identity.User;

/**
 * 建立日期 : 2013-4-12 下午4:38:39<br>
 * 作者 : balance<br>
 * 模块 : <br>
 * 描述 : <br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
public class Context implements Serializable {

	private static final long serialVersionUID = 4620137499401048150L;

	public static final String KEY = "_flow_context_";

	private String appId;// 应用Id

	private String flowKey;

	private String flowId;

	private String workId;// 工作Id

	private String formId;// 表单Id

	private String starter;// 启动人

	private String currentActor;// 当前处理人
	
	private String appName; // 应用名

	private Map<String, List<User>> historyUsers;// 流程历史处理人<activityName,users>

	public Context() {

	}

	public Context(String appId, String formId, String workId, String starter) {

	}

	/**
	 * 将处理过的任务上的人员信息添加到历史中
	 * 
	 * @param activityName
	 * @param users
	 */
	public void addHistoryUser(String activityName, List<User> users) {
		if (historyUsers == null)
			historyUsers = new HashMap<String, List<User>>();

		List<User> us = historyUsers.get(activityName);

		/* 退回时会重复添加人
		 * if (us == null)
			us = users;
		else{
			us.addAll(users);*/
			us=users;
		historyUsers.put(activityName, us);
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getWorkId() {
		return workId;
	}

	public void setWorkId(String workId) {
		this.workId = workId;
	}

	public String getFormId() {
		return formId;
	}

	public void setFormId(String formId) {
		this.formId = formId;
	}

	public String getStarter() {
		return starter;
	}

	public void setStarter(String starter) {
		this.starter = starter;
	}

	public String getCurrentActor() {
		return currentActor;
	}

	public void setCurrentActor(String currentActor) {
		this.currentActor = currentActor;
	}

	public Map<String, List<User>> getHistoryUsers() {
		return historyUsers;
	}

	public void setHistoryUsers(Map<String, List<User>> historyUsers) {
		this.historyUsers = historyUsers;
	}

	public String getFlowKey() {
		return flowKey;
	}

	public void setFlowKey(String flowKey) {
		this.flowKey = flowKey;
	}

	public String getFlowId() {
		return flowId;
	}

	public void setFlowId(String flowId) {
		this.flowId = flowId;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

}
